"""
登录购买页面方法
"""
from common.base import Base, get_driver
from selenium.webdriver.common.by import By


class LogInToBuy(Base):
    # 用户信息
    def userinfo(self, user, password):
    # # 输入用户名
    # def send_keys_login(self, user):
        self.send_keys((By.ID, "username"), user)

    # # 输入密码
    # def send_keys_password(self, password):
        self.send_keys((By.NAME, "password"), password)

    # # 点击登录
    # def click_login(self):
        self.click((By.NAME, "login"))


if __name__ == '__main__':
    # 创建浏览器驱动
    driver = get_driver()
    log_in_to_buy = LogInToBuy(driver)
    # 访问目标网址
    log_in_to_buy.get('http://localhost:8080/ecshop/flow.php?step=login')
    log_in_to_buy.userinfo(user="root123456", password="root123456")
    # log_in_to_buy.send_keys_login("root123456")
    # log_in_to_buy.send_keys_password("root123456")
    # log_in_to_buy.click_login()
    log_in_to_buy.quit(2)
